<extend name="Base/common"/>
<block name="style">
    <link href="__CSS__/event.css" rel="stylesheet" type="text/css"/>
    <link href="__ZUI__/lib/datetimepicker/datetimepicker.min.css" rel="stylesheet" type="text/css">
</block>
<block name="header">
    <include file="_nav"/>
</block>
<block name="body">
    <div id="frm-post-popup " class="white-popup1 boxShadowBorder col-md-12" style="">
        <h2>发起活动</h2>

        <div class="aline" style="margin-bottom: 35px"></div>
        <div>
            <div class="row">
                <div class="col-md-4">
                    <div class="controls">
                        <input type="file" id="upload_picture_cover" >

                        <div class="upload-img-box" style="margin-top: 20px;width: 350px">
                            <div style="font-size:3em;padding:2em 0;color: #ccc;text-align: center">暂无封面</div>
                        </div>
                    </div>
                    <p>为微信端想要图片不失真，请统一上传尺寸为509*269大小的图片</p>
                </div>
                <div class="col-md-8">
                    <form class="form-horizontal ajax-form" role="form" action="{:U('Event/Index/doPost')}"
                          method="post">
                        <div class="form-group has-feedback">
                            <label for="title" class="col-sm-2 control-label">标题</label>

                            <div class="col-sm-6">
                                <input id="title" name="title" class="form-control form_check" check-type="Text" value="" placeholder="标题" required />
                            </div>
                            <input type="hidden" name="id" id="id" value=""/>
                            <input type="hidden" name="cover_id" id="cover_id_cover" value=""/>
                        </div>


                        <div class="form-group ">
                            <label for="type_id" class="col-sm-2 control-label">分类</label>

                            <div class="col-sm-3">
                                <select id="type_id" name="type_id" class="form-control ">
                                    <volist name="tree" id="top">
                                        <option value="{$top.id}" >
                                        {$top.title}
                                        </option>
                                    </volist>
                                </select>
                            </div>


                        </div>

                        <div class="form-group has-feedback">
                            <label for="sldomain" class="col-sm-2 control-label">二级镜像域名</label>

                            <div class="col-sm-6">
                                <input id="sldomain" name="sldomain" class="form-control form_check" check-type="Text" value="" placeholder="h5game" required />
                            </div>

                        </div>

                        <div class="form-group has-feedback">
                            <label for="keyword" class="col-sm-2 control-label">关键字</label>

                            <div class="col-sm-6">
                                <input id="keyword" name="keyword" class="form-control form_check" check-type="Text" value="" placeholder="公众号回复关键字" required />
                            </div>

                        </div>

                        <div class="form-group has-feedback">
                            <label for="sponsor" class="col-sm-2 control-label">主办方</label>

                            <div class="col-sm-6">
                                <input id="sponsor" name="sponsor" class="form-control form_check" check-type="Text" value="" placeholder="请填写主办方" required />
                            </div>

                        </div>

                        <div class="form-group position">
                            <label for="email" class="col-sm-2 control-label">活动地址</label>

                            <div class="col-sm-10">
                                {:hook('J_China_City',array('province'=>1,'city'=>2,'district'=>3,'community'=>4))}
                            </div>
                        </div>

                        <div class="form-group  has-feedback">
                            <label for="address" class="col-sm-2 control-label">详细地址</label>

                            <div class="col-sm-6">
                                <input id="address"  name="address" class="form-control form_check" check-type="Text" value="" placeholder="详细地址" required/>
                                <input type="hidden" id="longitude" name="longitude" value="{$content.longitude}"/>
                                <input type="hidden" id="latitude" name="latitude" value="{$content.latitude}"/>
                                <input type="map" class="text input-large" readonly="readonly" id="map" name="map" value=''>
                                {:hook('EasyGo', array('name'=>"map",'value'=>I($content['longitude'], $content['latitude']),'extra'=>$content['map']))}
                            </div>

                        </div>

                        <div class="form-group  has-feedback">
                            <label for="" class="col-sm-2 control-label">活动时间</label>

                            <div class="col-sm-3">
                                <input type="text" id="sTime" name="sTime" class="time_d form-control form_check" readonly check-type="DateAndTime" value="" placeholder="开始时间" required/>
                            </div>

                            <div class="col-sm-3">
                                <input type="text" id="eTime" name="eTime" class="time_d form-control form_check" readonly check-type="DateAndTime"  value="" placeholder="结束时间" required/>
                            </div>
                        </div>

                        <div class="form-group  has-feedback">
                            <label for="limitCount" class="col-sm-2 control-label">人数</label>

                            <div class="col-sm-3">
                                <input id="limitCount" name="limitCount" class="form-control form_check" check-type="Num"  value="" placeholder="人数" required />
                            </div>

                        </div>
                        <div class="form-group  has-feedback">
                            <label for="deadline" class="col-sm-2 control-label">截止</label>

                            <div class="col-sm-4">
                                <input type="text" id="deadline" name="deadline" readonly class="time form-control form_check " check-type="Text" value="" placeholder="报名截止" required/>
                            </div>

                        </div>
                        <div class="form-group">
                            <label for="explain" class="col-sm-2 control-label">介绍</label>

                            <div class="col-sm-10">
                                <php>
                                    $config="toolbars:[['source','|','bold','italic','underline','fontsize','forecolor','justifyleft','fontfamily','|','map','emotion','insertimage','insertcode']]";
                                </php>

                                {:W('Common/Ueditor/editor',array('myeditor_edit','explain',$content['content'],'400px','250px',$config))}
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-1">
                                <button type="submit" class="btn btn-primary " href="{:U('Event/Index/doPost')}">提交
                                </button>

                            </div>
                            <div class="col-sm-8">
                                <button onclick="history.go(-1);" class="btn btn-default " href="{:U('Event/Index/doPost')}">返回
                                </button>
                            </div>

                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript" src="__JS__/form_check.js"></script>
    <script type="text/javascript" src="__ZUI__/lib/datetimepicker/datetimepicker.min.js" charset="UTF-8"></script>

    <script>

        $("#upload_picture_cover").uploadify({
            "height": 30,
            "swf": "__STATIC__/uploadify/uploadify.swf",
            "fileObjName": "download",
            "buttonText": "上传封面",
            "buttonClass": "uploadcover",
            "uploader": "{:U('Core/File/uploadPicture',array('session_id'=>session_id()))}",
            "width": 250,
            'removeTimeout': 1,
            'fileTypeExts': '*.jpg; *.png; *.gif;',
            "onUploadSuccess": uploadPicturecover,
            'overrideEvents': ['onUploadProgress', 'onUploadComplete', 'onUploadStart', 'onSelect'],
            'onFallback': function () {
                alert('未检测到兼容版本的Flash.');
            }, 'onUploadProgress': function (file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
                $("#cover_id_cover").parent().find('.upload-img-box').html(totalBytesUploaded + ' bytes uploaded of ' + totalBytesTotal + ' bytes.');
            }, 'onUploadComplete': function (file) {
                //alert('The file ' + file.name + ' finished processing.');
            }, 'onUploadStart': function (file) {
                //alert('Starting to upload ' + file.name);
            }, 'onQueueComplete': function (queueData) {
                // alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');
            }
        });
        function uploadPicturecover(file, data) {
            var data = $.parseJSON(data);
            var src = '';
            if (data.status) {
                $("#cover_id_cover").val(data.id);
                src = data.url || data.path
                $('.upload-img-box').html(
                        '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                );
            } else {
                toast.error('封面上传失败。', '温馨提示');
            }
        }



        $('.time').datetimepicker({
            language:'zh-CN',
            weekStart:1,
            todayBtn:1,
            autoclose:1,
            todayHighlight:1,
            startView:2,
            minView:0,
            forceParse:0,
            format: 'yyyy-mm-dd hh:ii'
        });

        $('.time_d').datetimepicker({
            language:'zh-CN',
            weekStart:1,
            todayBtn:1,
            autoclose:1,
            todayHighlight:1,
            startView:2,
            minView:0,
            forceParse:0,
            format: 'yyyy-mm-dd hh:ii'
        });
    </script>
</block>